home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume17 / delete / part01 next >
Encoding:
Internet Message Format  |  1991-02-25  |  59.6 KB

  1. From: jik@pit-manager.MIT.EDU (Jonathan I. Kamens)
  2. Newsgroups: comp.sources.misc
  3. Subject: v17i023:  delete - MIT Athena delete/undelete programs, Part01/04
  4. Message-ID: <1991Feb25.180641.4274@sparky.IMD.Sterling.COM>
  5. Date: 25 Feb 91 18:06:41 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 586a844b 5d371414 c6c6d3d2 3b164777
  8.  
  9. Submitted-by: Jonathan I. Kamens <jik@pit-manager.MIT.EDU>
  10. Posting-number: Volume 17, Issue 23
  11. Archive-name: delete/part01
  12.  
  13.   The following four shar files containing the source code for
  14. the MIT Project Athena "delete" suite of utilities, at patchlevel 12
  15. patchlevel 12.  The package allows for the recovery of deleted files 
  16. by renaming them instead of actually removing them completely.  See 
  17. the README file for additional information.
  18.  
  19.   Directly following the source code for delete will be three shar
  20. files containing the source code for the "com_err" error-handling
  21. library (at patchlevel 3), which you'll need to compile delete.  See
  22. com_err's README file for more information about it.  Note that this
  23. is NOT an official release of the com_err library by its authors (I
  24. don't think such a thing exists); I include it here only so people can
  25. compile delete.  Feel free to use the com_err library in your own
  26. programs, but be aware that it isn't necessarily going to be supported
  27. in any way.
  28.  
  29.   See the files mit-copyright.h in the delete sources and
  30. mit-sipb-copyright.h in the com_err sources, for copyright
  31. restrictions (basically, freely redistributable as long as the
  32. copyright stays, and there are no guarantees from MIT, but don't take
  33. my word for it, read the files).
  34.  
  35. Jonathan Kamens                          USnail:
  36. MIT Project Athena                11 Ashford Terrace
  37. jik@Athena.MIT.EDU                Allston, MA  02134
  38. Office: 617-253-8085                  Home: 617-782-0710
  39. ---
  40. #! /bin/sh
  41. # This is a shell archive.  Remove anything before this line, then unpack
  42. # it by saving it into a file and typing "sh file".  To overwrite existing
  43. # files, type "sh file -c".  You can also feed this as standard input via
  44. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  45. # will see the following message at the end:
  46. #        "End of archive 1 (of 4)."
  47. # Contents:  MANIFEST PATCHLEVEL README col.c col.h delete.h
  48. #   delete_errs.et directories.h errors.c errors.h expunge.h lsdel.h
  49. #   man1 man1/delete.1 man1/expunge.1 man1/lsdel.1 man1/purge.1
  50. #   man1/undelete.1 mit-copyright.h pattern.h shell_regexp.c
  51. #   shell_regexp.h stack.c stack.h undelete.h util.h
  52. # Wrapped by jik@pit-manager on Fri Feb 22 08:14:18 1991
  53. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  54. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  55.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  56. else
  57. echo shar: Extracting \"'MANIFEST'\" \(1168 characters\)
  58. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  59. X   File Name        Archive #    Description
  60. X-----------------------------------------------------------
  61. X MANIFEST                   1    This shipping list
  62. X Makefile                   2    
  63. X PATCHLEVEL                 1    
  64. X README                     1    
  65. X col.c                      1    
  66. X col.h                      1    
  67. X delete.c                   3    
  68. X delete.h                   1    
  69. X delete_errs.et             1    
  70. X directories.c              3    
  71. X directories.h              1    
  72. X errors.c                   1    
  73. X errors.h                   1    
  74. X expunge.c                  2    
  75. X expunge.h                  1    
  76. X lsdel.c                    2    
  77. X lsdel.h                    1    
  78. X man1                       1    
  79. X man1/delete.1              1    
  80. X man1/expunge.1             1    
  81. X man1/lsdel.1               1    
  82. X man1/purge.1               1    
  83. X man1/undelete.1            1    
  84. X mit-copyright.h            1    
  85. X pattern.c                  4    
  86. X pattern.h                  1    
  87. X shell_regexp.c             1    
  88. X shell_regexp.h             1    
  89. X stack.c                    1    
  90. X stack.h                    1    
  91. X undelete.c                 2    
  92. X undelete.h                 1    
  93. X util.c                     2    
  94. X util.h                     1    
  95. END_OF_FILE
  96. if test 1168 -ne `wc -c <'MANIFEST'`; then
  97.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  98. fi
  99. # end of 'MANIFEST'
  100. fi
  101. if test -f 'PATCHLEVEL' -a "${1}" != "-c" ; then 
  102.   echo shar: Will not clobber existing file \"'PATCHLEVEL'\"
  103. else
  104. echo shar: Extracting \"'PATCHLEVEL'\" \(3 characters\)
  105. sed "s/^X//" >'PATCHLEVEL' <<'END_OF_FILE'
  106. X12
  107. END_OF_FILE
  108. if test 3 -ne `wc -c <'PATCHLEVEL'`; then
  109.     echo shar: \"'PATCHLEVEL'\" unpacked with wrong size!
  110. fi
  111. # end of 'PATCHLEVEL'
  112. fi
  113. if test -f 'README' -a "${1}" != "-c" ; then 
  114.   echo shar: Will not clobber existing file \"'README'\"
  115. else
  116. echo shar: Extracting \"'README'\" \(3435 characters\)
  117. sed "s/^X//" >'README' <<'END_OF_FILE'
  118. X                   OVERVIEW
  119. X
  120. XThis archive contains the sources for five programs (well, actually,
  121. Xfour, since one is a symbolic link):
  122. X
  123. X    delete
  124. X    undelete
  125. X    expunge
  126. X    purge
  127. X    lsdel
  128. X
  129. XThe programs were written at Project Athena in response to the problem
  130. Xwhich many novice Unix users have with accidentally deleting files
  131. Xthey didn't want to delete (Hell, I've done it :-).
  132. X
  133. X
  134. X             SUPPORTED PLATFORMS
  135. X
  136. XI've personally compiled these sources under Vax 4.3BSD, IBM AOS 4.3,
  137. XMach on the NeXT Machine (with the "-bsd" flag to the compiler),
  138. XUltrix 3.1 on the DECstation 3100, SunOS 4.0, A/UX, and HP-UX, and I
  139. Xassume they should compile with minimal trouble on other
  140. Xarchitectures.  If you make it compile on another platform and you
  141. Xhave to make changes, please send me patches.
  142. X
  143. X
  144. X             WHAT YOU NEED TO DO
  145. X
  146. X1. Compile the com_err library (see below for more details) and
  147. X   install it if you want to (you'll have to modify the delete
  148. X   Makefile a bit if you don't).
  149. X
  150. X2. Edit the Makefile to fit your site.  See below for details.
  151. X
  152. X3. Compile away!  Type "make" to make without installing, or "make
  153. X   install" to install binaries and man pages in the locations you
  154. X   specified when you edited the Makefile.
  155. X
  156. X
  157. X               CUSTOMIZING THE MAKEFILE
  158. X
  159. XYou are probably going to have to do one or more of the following to
  160. Xmake the Makefile work for you.
  161. X
  162. X1. Change the install binary directory and install man page directory
  163. X   (and possibly man section).
  164. X
  165. X2. Change the ETINCS and ETLDFLAGS variables to point to the right
  166. X   place.  Also, change the COMPILE_ET variable to point to a
  167. X   compile_et executable if you haven't installed it somewhere in your
  168. X   search path.
  169. X
  170. X3. If you want to be able to build dependencies, then change DEPEND to
  171. X   the name of the program on your system that knows how to do that.
  172. X
  173. X4. If your system is SYSV-like (e.g. it uses strchr and strrchr
  174. X   instead of index and rindex, or it has memcpy and doesn't have
  175. X   bcopy), and your compile doesn't define the symbol SYSV
  176. X   automatically, then put "-DSYSV" in the DEFINES variable.
  177. X
  178. X5. If you want to support Andrew File System (AFS) mountpoint
  179. X   detection, and you have AFS include files and libraries available
  180. X   to you, then uncomment the variables starting with "AFS" and set
  181. X   them appropriately.
  182. X
  183. X
  184. X               COM_ERR LIBRARY
  185. X
  186. XIn order to compile delete, you need to get your hands on the com_err
  187. Xpackage, which was written by members of the MIT Student Information
  188. XProcessing Board (SIPB).  If com_err isn't available from the place
  189. Xfrom which you got the delete sources, you can get it from volume 22
  190. Xof the comp.sources.unix archives, under the name "et".  You should
  191. Xcompile the library and compile_et utility that comes with it and then
  192. Xeither install them in a "standard location" on your machine or modify
  193. Xthe delete Makefile so that it knows where they are.  The delete
  194. XMakefile does not compile them by default, since they are already
  195. Xcompiled and installed at Athena, so you should compile and install
  196. Xthem separately from delete.
  197. X
  198. X
  199. X                 FINAL NOTES
  200. X
  201. XAs usual, suggestions and bug fixes are always welcomed.
  202. X
  203. XMy address:
  204. X
  205. XJonathan Kamens                          USnail:
  206. XMIT Project Athena                11 Ashford Terrace
  207. Xjik@Athena.MIT.EDU                Allston, MA  02134
  208. XOffice: 617-253-8085                  Home: 617-782-0710
  209. X
  210. XP.S. Please see the file "mit-copyright.h" for copying and
  211. Xredistribution information.  Copyright 1991 Massachusetts Institute of
  212. XTechnology.  All Rights Reserved.  Etc.
  213. END_OF_FILE
  214. if test 3435 -ne `wc -c <'README'`; then
  215.     echo shar: \"'README'\" unpacked with wrong size!
  216. fi
  217. # end of 'README'
  218. fi
  219. if test -f 'col.c' -a "${1}" != "-c" ; then 
  220.   echo shar: Will not clobber existing file \"'col.c'\"
  221. else
  222. echo shar: Extracting \"'col.c'\" \(5154 characters\)
  223. sed "s/^X//" >'col.c' <<'END_OF_FILE'
  224. X/*
  225. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/col.c,v $
  226. X * $Author: jik $
  227. X *
  228. X * This program is part of a package including delete, undelete,
  229. X * lsdel, expunge and purge.  The software suite is meant as a
  230. X * replacement for rm which allows for file recovery.
  231. X * 
  232. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  233. X * For copying and distribution information, see the file "mit-copyright.h."
  234. X */
  235. X
  236. X#if (!defined(lint) && !defined(SABER))
  237. X     static char rcsid_col_c[] = "$Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/col.c,v 1.7 90/06/06 19:05:56 jik Exp $";
  238. X#endif
  239. X
  240. X/*
  241. X * Note that this function has a lot of options I'm not really using
  242. X * because I took it out of other code that needed a lot more
  243. X * versatility.
  244. X */
  245. X
  246. X#include <stdio.h>
  247. X#ifdef SYSV
  248. X#include <string.h>
  249. X#define index strchr
  250. X#define rindex strrchr
  251. X#else
  252. X#include <strings.h>
  253. X#endif /* SYSV */
  254. X#include "errors.h"
  255. X#include "delete_errs.h"
  256. X#include "col.h"
  257. X#include "mit-copyright.h"
  258. X
  259. X
  260. Xstatic int calc_string_width(), calc_widths(), num_width();
  261. Xstatic void trim_strings();
  262. X
  263. Xint column_array(strings, num_to_print, screen_width, column_width,
  264. X         number_of_columns, margin, spread_flag, 
  265. X         number_flag, var_col_flag, outfile)
  266. Xchar **strings;
  267. XFILE *outfile;
  268. X{
  269. X     char buf[BUFSIZ];
  270. X     int updown, leftright, height;
  271. X     int string_width;
  272. X     int numwidth;
  273. X
  274. X     numwidth = num_width(num_to_print);
  275. X     if (! var_col_flag) {
  276. X      string_width = calc_string_width(column_width, margin, number_flag,
  277. X                       num_to_print);
  278. X      if (string_width <= 0) {
  279. X           set_error(COL_COLUMNS_TOO_THIN);
  280. X           error("calc_string_width");
  281. X           return error_code;
  282. X      }
  283. X      trim_strings(strings, num_to_print, string_width);
  284. X     } else if (calc_widths(strings, &screen_width, &column_width,
  285. X                &number_of_columns, num_to_print, &margin,
  286. X                spread_flag, number_flag)) {
  287. X      error("calc_widths");
  288. X      return error_code;
  289. X     }
  290. X     height = num_to_print / number_of_columns;
  291. X     if (num_to_print % number_of_columns)
  292. X      height++;
  293. X     
  294. X     if (number_flag) for (updown = 0; updown < height; updown++) {
  295. X      for (leftright = updown; leftright < num_to_print; ) {
  296. X           (void) sprintf(buf, "%*d. %s", numwidth, leftright+1,
  297. X                  strings[leftright]);
  298. X           if ((leftright += height) >= num_to_print)
  299. X            fprintf(outfile, "%s", buf );
  300. X           else
  301. X            fprintf(outfile, "%*s", -column_width, buf);
  302. X      }
  303. X      fprintf(outfile, "\n");
  304. X     } else for (updown = 0; updown < height; updown++) {
  305. X      for (leftright = updown; leftright < num_to_print; ) {
  306. X           (void) sprintf(buf, "%s", strings[leftright]);
  307. X           if ((leftright += height) >= num_to_print)
  308. X            fprintf(outfile, "%s", buf );
  309. X           else
  310. X            fprintf(outfile, "%*s", -column_width, buf);
  311. X      }
  312. X      fprintf(outfile, "\n");
  313. X     }
  314. X     return 0;
  315. X}
  316. X
  317. Xstatic int calc_string_width(column_width, margin, number_flag, max_number)
  318. X{
  319. X     int string_width;
  320. X     
  321. X     string_width = column_width - margin;
  322. X     if (number_flag)
  323. X      string_width = string_width - num_width(max_number) - strlen(". ");
  324. X     return string_width;
  325. X}
  326. X
  327. X
  328. Xstatic void trim_strings(strings, number, width)
  329. Xchar **strings;
  330. X{
  331. X     int loop;
  332. X     
  333. X     for (loop = 0; loop < number; loop++)
  334. X      if (strlen(strings[loop]) > width)
  335. X           strings[loop][width] = '\0';
  336. X}
  337. X
  338. X
  339. Xstatic int calc_widths(strings, screen_width, column_width, number_of_columns,
  340. X               num_to_print, margin, spread_flag, number_flag)
  341. Xint *screen_width, *column_width, *number_of_columns, *margin;
  342. Xchar **strings;
  343. X{
  344. X     int loop;
  345. X     int maxlen, templen;
  346. X     int spread;
  347. X     
  348. X     maxlen = templen = 0;
  349. X     for (loop = 0; loop < num_to_print; loop++)
  350. X      if (maxlen < (templen = strlen(strings[loop])))
  351. X           maxlen = templen;
  352. X
  353. X     *column_width = maxlen;
  354. X     
  355. X     if (number_flag)
  356. X      *column_width = *column_width + num_width(num_to_print) +
  357. X           strlen(". ");
  358. X
  359. X     if (! spread_flag) {
  360. X      *column_width += *margin;
  361. X      if (! *number_of_columns) {
  362. X           *number_of_columns = *screen_width / *column_width;
  363. X           if (! *number_of_columns) {
  364. X            (*number_of_columns)++;
  365. X            *column_width -= *margin;
  366. X            *margin = 0;
  367. X            *screen_width = *column_width;
  368. X           }
  369. X      }
  370. X      else
  371. X           *screen_width = *number_of_columns * *column_width;
  372. X     } else {
  373. X      if (! *number_of_columns) {
  374. X           *number_of_columns = *screen_width / (*column_width + *margin);
  375. X           if (! *number_of_columns) {
  376. X            (*number_of_columns)++;
  377. X            *screen_width = *column_width;
  378. X            *margin = 0;
  379. X           }
  380. X           spread = (*screen_width - *number_of_columns * *column_width)
  381. X            / *number_of_columns;
  382. X           *column_width += spread;
  383. X      }
  384. X      else {
  385. X           if (*number_of_columns * (*column_width + *margin) >
  386. X           *screen_width) {
  387. X            *column_width += *margin;
  388. X            *screen_width = *column_width;
  389. X           } else {
  390. X            spread = (*screen_width - (*number_of_columns *
  391. X                           *column_width)) /
  392. X                            *number_of_columns;
  393. X            *column_width += spread;
  394. X           }
  395. X      }
  396. X     }
  397. X     return 0;
  398. X}
  399. X
  400. X
  401. X           
  402. X
  403. Xstatic int num_width(number)
  404. Xint number;
  405. X{
  406. X     char buf[BUFSIZ];
  407. X
  408. X     (void) sprintf(buf, "%d", number);
  409. X     return strlen(buf);
  410. X}
  411. END_OF_FILE
  412. if test 5154 -ne `wc -c <'col.c'`; then
  413.     echo shar: \"'col.c'\" unpacked with wrong size!
  414. fi
  415. # end of 'col.c'
  416. fi
  417. if test -f 'col.h' -a "${1}" != "-c" ; then 
  418.   echo shar: Will not clobber existing file \"'col.h'\"
  419. else
  420. echo shar: Extracting \"'col.h'\" \(1507 characters\)
  421. sed "s/^X//" >'col.h' <<'END_OF_FILE'
  422. X/*
  423. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/col.h,v $
  424. X * $Author: jik $
  425. X *
  426. X * This header file is part of a package including delete, undelete,
  427. X * lsdel, expunge and purge.  The software suite is meant as a
  428. X * replacement for rm which allows for file recovery.
  429. X * 
  430. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  431. X * For copying and distribution information, see the file "mit-copyright.h."
  432. X */
  433. X#include "mit-copyright.h"
  434. X
  435. X/*
  436. X * DEF_COL_WIDTH: the column with to try to use if none is specified.
  437. X * DEF_WAIT: 1 if the program is supposed to wait for stdin to get to
  438. X *           end-of-file and then print out everything in order in
  439. X *           columns by default.  If this is 0, then the default is
  440. X *           for the program to print across instead of down and to
  441. X *           print as it receives input from stdin.
  442. X * DEF_VAR_COLS: if 1, use variable-width columns based on text width.
  443. X *               if 1, DEF_WAIT must be true.
  444. X * DEF_SCR_WIDTH: default screen width
  445. X * DEF_NUM_ITEMS: if 1, number each item
  446. X * DEF_MARGIN: the default margin in between columns of text
  447. X */ 
  448. X#define DEF_COL_WIDTH 20
  449. X#define DEF_WAIT 1
  450. X#define DEF_VAR_COLS 1
  451. X#define DEF_SCR_WIDTH 80
  452. X#define DEF_NUM_ITEMS 1
  453. X#define DEF_MARGIN 2
  454. X /* This is used for when we need a guess as to how long a number will */
  455. X /* be when printed.  Also, if we are supposed to work in wait mode    */
  456. X /* and are not given a maxitems value, this is what is used.          */
  457. X#define DEF_MAX_ITEMS 10000
  458. END_OF_FILE
  459. if test 1507 -ne `wc -c <'col.h'`; then
  460.     echo shar: \"'col.h'\" unpacked with wrong size!
  461. fi
  462. # end of 'col.h'
  463. fi
  464. if test -f 'delete.h' -a "${1}" != "-c" ; then 
  465.   echo shar: Will not clobber existing file \"'delete.h'\"
  466. else
  467. echo shar: Extracting \"'delete.h'\" \(557 characters\)
  468. sed "s/^X//" >'delete.h' <<'END_OF_FILE'
  469. X/*
  470. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/delete.h,v $
  471. X * $Author: jik $
  472. X * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/delete.h,v 1.4 89/10/23 13:43:22 jik Exp $
  473. X * 
  474. X * This file is part of a package including delete, undelete,
  475. X * lsdel, expunge and purge.  The software suite is meant as a
  476. X * replacement for rm which allows for file recovery.
  477. X * 
  478. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  479. X * For copying and distribution information, see the file "mit-copyright.h."
  480. X */
  481. X
  482. X#include "mit-copyright.h"
  483. END_OF_FILE
  484. if test 557 -ne `wc -c <'delete.h'`; then
  485.     echo shar: \"'delete.h'\" unpacked with wrong size!
  486. fi
  487. # end of 'delete.h'
  488. fi
  489. if test -f 'delete_errs.et' -a "${1}" != "-c" ; then 
  490.   echo shar: Will not clobber existing file \"'delete_errs.et'\"
  491. else
  492. echo shar: Extracting \"'delete_errs.et'\" \(1551 characters\)
  493. sed "s/^X//" >'delete_errs.et' <<'END_OF_FILE'
  494. X#     Copyright 1988 Massachusetts Institute of Technology.
  495. X#
  496. X#     For copying and distribution information, see the file
  497. X#     "mit-copyright.h".
  498. X#
  499. X#     $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/delete_errs.et,v $
  500. X#     $Author: jik $
  501. X#     $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/delete_errs.et,v 1.3 89/12/28 14:44:22 jik Exp $
  502. X#
  503. X
  504. X    et    del
  505. X
  506. Xec REGEXP_MISSING_QUOTED_CHAR,
  507. X    "missing quoted character after backslash"
  508. Xec REGEXP_MISSING_BRACE,
  509. X    "missing ]"
  510. Xec REGEXP_EMPTY_BRACES,
  511. X    "illegal empty braces"
  512. Xec DIR_NOT_DIRECTORY,
  513. X    "internal error: directory operation on non-directory"
  514. Xec DIR_IMPOSSIBLE_ERROR,
  515. X    "interal error: something that shouldn't happen just did"
  516. Xec COL_COLUMNS_TOO_THIN,
  517. X    "possible internal error: listing columns too thin"
  518. Xec DELETE_IS_DOTFILE,
  519. X    "can't delete `.' or `..'"
  520. Xec DELETE_CANT_DEL_DIR,
  521. X    "can't delete (not file)"
  522. Xec DELETE_DIR_NOT_EMPTY,
  523. X    "can't delete (directory not empty)"
  524. Xec DELETE_CANT_DEL_FILE,
  525. X    "can't delete (not directory)"
  526. Xec DELETE_NOT_DELETED,
  527. X    ""
  528. Xec UNDEL_NOT_UNDELETED,
  529. X    ""
  530. Xec NO_HOME_DIR,
  531. X    "can't find home directory"
  532. Xec INTERNAL_ERROR,
  533. X    "strange internal error"
  534. Xec ENOMATCH,
  535. X    "no match"
  536. Xec EXPUNGE_NOT_EXPUNGED,
  537. X    ""
  538. Xec PURGE_TOO_MANY_ARGS,
  539. X    "command takes no arguments"
  540. Xec PAT_NO_FILES_REQUESTED,
  541. X    "internal error: no files requested in call to find_matches or do_match"
  542. Xec PAT_IS_MOUNT,
  543. X    "ignored (is mount point)"
  544. Xec STACK_BAD_OP,
  545. X    "internal error: call to dostack with undefined stack operation"
  546. Xec STACK_EMPTY,
  547. X    "internal error: attempt to pop from empty stack"
  548. X
  549. X    end
  550. X
  551. END_OF_FILE
  552. if test 1551 -ne `wc -c <'delete_errs.et'`; then
  553.     echo shar: \"'delete_errs.et'\" unpacked with wrong size!
  554. fi
  555. # end of 'delete_errs.et'
  556. fi
  557. if test -f 'directories.h' -a "${1}" != "-c" ; then 
  558.   echo shar: Will not clobber existing file \"'directories.h'\"
  559. else
  560. echo shar: Extracting \"'directories.h'\" \(3306 characters\)
  561. sed "s/^X//" >'directories.h' <<'END_OF_FILE'
  562. X/*
  563. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/directories.h,v $
  564. X * $Author: jik $
  565. X * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/directories.h,v 1.10 91/02/22 06:33:34 jik Exp $
  566. X * 
  567. X * This file is part of a package including delete, undelete,
  568. X * lsdel, expunge and purge.  The software suite is meant as a
  569. X * replacement for rm which allows for file recovery.
  570. X * 
  571. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  572. X * For copying and distribution information, see the file "mit-copyright.h."
  573. X */
  574. X
  575. X#include "mit-copyright.h"
  576. X
  577. Xtypedef short Boolean;
  578. X#define True            (Boolean) 1
  579. X#define False            (Boolean) 0
  580. X
  581. X
  582. X#define size_to_k(x)        ((x) / 1024 + (((x) % 1024) ? 1 : 0))
  583. X
  584. X#define FOLLOW_LINKS        1
  585. X#define DONT_FOLLOW_LINKS    0
  586. X
  587. X#define DIR_MATCH        1
  588. X#define DIR_NO_MATCH        0
  589. X
  590. Xtypedef struct mystat {
  591. X     dev_t st_dev;
  592. X     ino_t st_ino;
  593. X     unsigned short st_mode;
  594. X     off_t st_size;
  595. X     time_t st_ctime;
  596. X#ifdef notdef
  597. X     /*
  598. X      * I've tried, unsuccessfully, to figure out exactly what this
  599. X      * field means and how I can use it.  Supposedly, it indicates
  600. X      * the number of blocks the file actually occupies, i.e. the size
  601. X      * of the file minus any holes in it there may be.  The question,
  602. X      * however, is this: what's a "block?"
  603. X      *
  604. X      * At first, I thought that a block is as big as f_bsize returned
  605. X      * by a statfs on the file.  But that doesn't prove to be the
  606. X      * case, because my home directory in AFS has f_bsize of 8192,
  607. X      * st_size of 8192, and st_blocks of 16 (!!), indicating that a
  608. X      * block size of 512 bytes is being used.  Where does that size
  609. X      * come from, and why isn't it consistent with the f_bsize
  610. X      * retrieved from statfs?
  611. X      *
  612. X      * Until someone can answer these questions for me enough that
  613. X      * I'm willing to trust the value in this field, I can't use it.
  614. X      * Besides that, it doesn't even exist in the POSIX stat
  615. X      * structure, so I'm not even sure it's worth trying to use it.
  616. X      *
  617. X      * Here's another dilemma: When I do a statfs on my home
  618. X      * directory in AFS, it tells me that the f_bsize is 8192.  If
  619. X      * that's the case, then when I create a one-character file in my
  620. X      * home directory, my quota usage should go up by 8k.  But it
  621. X      * doesn't, it goes up by just 1k.  Which means that the f_bsize
  622. X      * I'm getting from statfs has nothing to do with the minimum
  623. X      * block size of the filesystem.  So what *does* it have to do
  624. X      * with?
  625. X      */
  626. X     long st_blocks;
  627. X#endif
  628. X} mystat;
  629. X
  630. X     
  631. Xtypedef struct filrec {
  632. X     char name[MAXNAMLEN];
  633. X     struct filrec *previous;
  634. X     struct filrec *parent;
  635. X     struct filrec *dirs;
  636. X     struct filrec *files;
  637. X     struct filrec *next;
  638. X     Boolean specified;
  639. X     Boolean freed;
  640. X     struct mystat specs;
  641. X} filerec;
  642. X
  643. X
  644. X
  645. Xint add_directory_to_parent();
  646. Xint add_file_to_parent();
  647. Xint add_path_to_tree();
  648. Xint find_child();
  649. Xfilerec *first_in_directory();
  650. Xfilerec *first_specified_in_directory();
  651. Xfilerec *get_cwd_tree();
  652. Xfilerec *get_root_tree();
  653. Xfilerec *next_directory();
  654. Xfilerec *next_in_directory();
  655. Xfilerec *next_leaf();
  656. Xfilerec *next_specified_directory();
  657. Xfilerec *next_specified_in_directory();
  658. Xfilerec *next_specified_leaf();
  659. X
  660. Xint get_leaf_path();
  661. Xint accumulate_names();
  662. X
  663. Xvoid free_leaf();
  664. END_OF_FILE
  665. if test 3306 -ne `wc -c <'directories.h'`; then
  666.     echo shar: \"'directories.h'\" unpacked with wrong size!
  667. fi
  668. # end of 'directories.h'
  669. fi
  670. if test -f 'errors.c' -a "${1}" != "-c" ; then 
  671.   echo shar: Will not clobber existing file \"'errors.c'\"
  672. else
  673. echo shar: Extracting \"'errors.c'\" \(1482 characters\)
  674. sed "s/^X//" >'errors.c' <<'END_OF_FILE'
  675. X/*
  676. X * $Source: /afs/athena.mit.edu/astaff/project/delete/src/RCS/errors.c,v $
  677. X * $Author: jik $
  678. X *
  679. X * This program is part of a package including delete, undelete,
  680. X * lsdel, expunge and purge.  The software suite is meant as a
  681. X * replacement for rm which allows for file recovery.
  682. X * 
  683. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  684. X * For copying and distribution information, see the file "mit-copyright.h."
  685. X */
  686. X
  687. X#if (!defined(lint) && !defined(SABER))
  688. X     static char rcsid_errors_c[] = "$Header: /afs/athena.mit.edu/astaff/project/delete/src/RCS/errors.c,v 1.3 90/11/12 02:28:28 jik Exp $";
  689. X#endif
  690. X
  691. X#include <com_err.h>
  692. X#include <stdio.h>
  693. X#include "delete_errs.h"
  694. X#include "mit-copyright.h"
  695. X
  696. Xchar *whoami;
  697. Xint error_reported = 1;
  698. Xint error_occurred = 0;
  699. Xint report_errors = 1;
  700. Xint error_code = 0;
  701. X
  702. X/*
  703. X * Proper use of this procedure requires strict adherance to the way
  704. X * it is supposed to be used by all procedures in a program.  Whenever
  705. X * there is an error, set_error must be called with the error value.
  706. X * Then, either the procedure that detects the error must call
  707. X * error(), or it must pass the error up to its parent for the parent
  708. X * to report.
  709. X */
  710. X
  711. X
  712. Xvoid error(str)
  713. Xchar *str;
  714. X{
  715. X     if (report_errors && (! error_reported)) {
  716. X      if (*str)
  717. X           fprintf(stderr, "%s: %s: %s\n", whoami, str,
  718. X               error_message(error_code));
  719. X      else
  720. X           fprintf(stderr, "%s: %s\n", whoami, error_message(error_code));
  721. X     }
  722. X     error_reported = 1;
  723. X}
  724. END_OF_FILE
  725. if test 1482 -ne `wc -c <'errors.c'`; then
  726.     echo shar: \"'errors.c'\" unpacked with wrong size!
  727. fi
  728. # end of 'errors.c'
  729. fi
  730. if test -f 'errors.h' -a "${1}" != "-c" ; then 
  731.   echo shar: Will not clobber existing file \"'errors.h'\"
  732. else
  733. echo shar: Extracting \"'errors.h'\" \(883 characters\)
  734. sed "s/^X//" >'errors.h' <<'END_OF_FILE'
  735. X/*
  736. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/errors.h,v $
  737. X * $Author: jik $
  738. X * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/errors.h,v 1.2 89/11/06 21:27:23 jik Exp $
  739. X * 
  740. X * This file is part of a package including delete, undelete,
  741. X * lsdel, expunge and purge.  The software suite is meant as a
  742. X * replacement for rm which allows for file recovery.
  743. X * 
  744. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  745. X * For copying and distribution information, see the file "mit-copyright.h."
  746. X */
  747. X#include "mit-copyright.h"
  748. X
  749. Xextern char *whoami;
  750. Xextern int error_reported;
  751. Xextern int error_occurred;
  752. Xextern int report_errors;
  753. Xextern int error_code;
  754. X
  755. Xvoid error();
  756. X
  757. X#define set_error(cd) {error_code = cd; error_reported = 0; error_occurred = 1;}
  758. X#define set_warning(cd) {error_code = cd; error_reported = 0;}
  759. X#define set_status(cd) {error_code = cd;}
  760. END_OF_FILE
  761. if test 883 -ne `wc -c <'errors.h'`; then
  762.     echo shar: \"'errors.h'\" unpacked with wrong size!
  763. fi
  764. # end of 'errors.h'
  765. fi
  766. if test -f 'expunge.h' -a "${1}" != "-c" ; then 
  767.   echo shar: Will not clobber existing file \"'expunge.h'\"
  768. else
  769. echo shar: Extracting \"'expunge.h'\" \(656 characters\)
  770. sed "s/^X//" >'expunge.h' <<'END_OF_FILE'
  771. X/*
  772. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/expunge.h,v $
  773. X * $Author: jik $
  774. X * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/expunge.h,v 1.4 89/10/23 13:37:05 jik Exp $
  775. X * 
  776. X * This file is part of a package including delete, undelete,
  777. X * lsdel, expunge and purge.  The software suite is meant as a
  778. X * replacement for rm which allows for file recovery.
  779. X * 
  780. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  781. X * For copying and distribution information, see the file "mit-copyright.h."
  782. X */
  783. X#include "mit-copyright.h"
  784. X
  785. X#define ERROR_MASK        1
  786. X#define NO_DELETE_MASK        2
  787. X#define NO_TIMEOUT_MASK        4
  788. X
  789. Xint get_the_files();
  790. END_OF_FILE
  791. if test 656 -ne `wc -c <'expunge.h'`; then
  792.     echo shar: \"'expunge.h'\" unpacked with wrong size!
  793. fi
  794. # end of 'expunge.h'
  795. fi
  796. if test -f 'lsdel.h' -a "${1}" != "-c" ; then 
  797.   echo shar: Will not clobber existing file \"'lsdel.h'\"
  798. else
  799. echo shar: Extracting \"'lsdel.h'\" \(623 characters\)
  800. sed "s/^X//" >'lsdel.h' <<'END_OF_FILE'
  801. X/*
  802. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/lsdel.h,v $
  803. X * $Author: jik $
  804. X * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/lsdel.h,v 1.4 89/10/23 13:33:51 jik Exp $
  805. X * 
  806. X * This file is part of a package including delete, undelete,
  807. X * lsdel, expunge and purge.  The software suite is meant as a
  808. X * replacement for rm which allows for file recovery.
  809. X * 
  810. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  811. X * For copying and distribution information, see the file "mit-copyright.h."
  812. X */
  813. X#include "mit-copyright.h"
  814. X
  815. X#define ERROR_MASK 1
  816. X#define NO_DELETE_MASK 2
  817. X
  818. Xint get_the_files();
  819. END_OF_FILE
  820. if test 623 -ne `wc -c <'lsdel.h'`; then
  821.     echo shar: \"'lsdel.h'\" unpacked with wrong size!
  822. fi
  823. # end of 'lsdel.h'
  824. fi
  825. if test ! -d 'man1' ; then
  826.     echo shar: Creating directory \"'man1'\"
  827.     mkdir 'man1'
  828. fi
  829. if test -f 'man1/delete.1' -a "${1}" != "-c" ; then 
  830.   echo shar: Will not clobber existing file \"'man1/delete.1'\"
  831. else
  832. echo shar: Extracting \"'man1/delete.1'\" \(4217 characters\)
  833. sed "s/^X//" >'man1/delete.1' <<'END_OF_FILE'
  834. X.\"    $Source: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/delete.1,v $
  835. X.\"    $Author: jik $
  836. X.\"    $Header: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/delete.1,v 1.5 89/09/14 03:42:51 jik Exp $
  837. X.\"
  838. X.\" Copyright 1989 by the Massachusetts Institute of Technology.  All
  839. X.\" rights reserved.  The file /usr/include/mit-copyright.h specifies
  840. X.\" the terms and conditions for redistribution.
  841. X.\"
  842. X.\"
  843. X.TH DELETE 1 "January 26, 1988" "MIT Project Athena"
  844. X.ds ]W MIT Project Athena
  845. X.SH NAME
  846. Xdelete \- a recoverable file-deletion utility
  847. X.SH SYNOPSIS
  848. X.B delete
  849. X[
  850. X.B \-r
  851. X] [
  852. X.B \-i
  853. X] [
  854. X.B \-f
  855. X] [
  856. X.B \-n
  857. X] [
  858. X.B \-v
  859. X] [
  860. X.B \-e
  861. X] [
  862. X.B \-F
  863. X] [
  864. X.B \-D
  865. X] [
  866. X.B \-\|\-
  867. X] filename ...
  868. X.PP
  869. X.SH DESCRIPTION
  870. X.I Delete
  871. Xmarks files and directories for later permanent removal (by renaming
  872. Xthem with a prefix of \fI.#\fR).  Files accidentally marked for deletion
  873. Xcan be recovered using
  874. X.I undelete(1).
  875. XMarked files are periodically
  876. Xremoved automatically by the system; they can also be removed on demand
  877. X(see \fIpurge\fR(1) and \fIexpunge\fR(1) for details).
  878. XUsers can list files which have been marked for
  879. Xremoval but have not yet been removed using \fIlsdel\fR(1).
  880. X.PP
  881. XIf the user does not have write permission to a file, its permissions
  882. Xare printed and the user is asked whether the file should be removed.
  883. XIf the first character of the response line is \fIy\fR the file is
  884. Xremoved, otherwise it remains.
  885. X.PP
  886. XUsers wishing to retain the user interface of \fIrm\fR(1)
  887. Xand \fIrmdir\fR(1)
  888. Xwhile still being able to recover accidentally removed files can do so
  889. Xby aliasing
  890. X.I rm
  891. Xto
  892. X.I delete \-F \-e
  893. Xand
  894. X.I rmdir
  895. Xto
  896. X.I delete \-D \-e
  897. X(see below).
  898. X.SH OPTIONS
  899. X.I Delete
  900. Xaccepts the following command-line options:
  901. X.TP
  902. X.B \-r
  903. XIf a designated filename is a non-empty directory,
  904. X.I delete
  905. Xwill signal an error unless the
  906. X.B \-r
  907. Xoption is specified.  In that case,
  908. X.I delete
  909. Xrecursively deletes the directory's entire contents and the directory
  910. Xitself.  If the
  911. X.B \-F
  912. Xoption is specified (see below),
  913. X.I delete
  914. Xwill signal an error even if the directory is empty.
  915. X.TP
  916. X.B \-i
  917. XCauses
  918. X.I delete
  919. Xto ask whether to delete each file, and, in recursive
  920. Xmode, whether to examine each directory.
  921. X.TP
  922. X.B \-f
  923. XPrevents
  924. X.I delete
  925. Xfrom asking any questions and from reporting any errors.
  926. X.TP
  927. X.B \-n
  928. XNo file removals are performed.  Instead,
  929. X.I delete
  930. Xprints to the standard output the files that it would remove were the
  931. X.B \-n
  932. Xoption not specified.
  933. X.TP
  934. X.B \-v
  935. XCauses
  936. X.I delete
  937. Xto report each file as it is deleted.
  938. X.TP
  939. X.B \-e
  940. XCauses
  941. X.I delete
  942. Xto emulate \fIrm\fR(1) and \fIrmdir\fR(1) as much as it can (i.e.
  943. Xerror and status messages and other peculiarities of \fIrm\fR(1) and
  944. X\fIrmdir\fI(1)).
  945. X.TP
  946. X.B \-F
  947. XCauses
  948. X.I delete
  949. Xto emulate
  950. X.I rm
  951. Xby preventing it from removing even empty directories when the
  952. X.B \-r
  953. Xoption is not specified.
  954. X.TP
  955. X.B \-D
  956. XCauses
  957. X.I delete
  958. Xto emulate
  959. X.I rmdir
  960. Xby preventing it from removing anything but empty directories.
  961. X.TP
  962. X.B \-\|\-
  963. XTwo dashes indicate that all the arguments following it are to be treated as
  964. Xfile names, even if they start with a dash.
  965. X.SH "SEE ALSO"
  966. Xundelete(1), purge(1), expunge(1), lsdel(1), rm(1), rmdir(1)
  967. X.SH AUTHOR
  968. XJonathan I. Kamens (MIT-Project Athena)
  969. X.SH COPYRIGHT
  970. XCopyright (c) 1989 by the Massachusetts Institute of Technology.
  971. X.PP
  972. XAll rights reserved.
  973. X.PP
  974. XPermission to use, copy, modify, and distribute this software and its
  975. Xdocumentation for any purpose and without fee is hereby granted,
  976. Xprovided that the above copyright notice appear in all copies and that
  977. Xboth that copyright notice and this permission notice appear in
  978. Xsupporting documentation, and that the name of the Massachusetts
  979. XInstitute of Technology (M.I.T.) not be used in advertising or publicity
  980. Xpertaining to distribution of the software without specific, written
  981. Xprior permission.
  982. X.PP
  983. XM.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  984. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  985. XM.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  986. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  987. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  988. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  989. XSOFTWARE.
  990. X
  991. X
  992. END_OF_FILE
  993. if test 4217 -ne `wc -c <'man1/delete.1'`; then
  994.     echo shar: \"'man1/delete.1'\" unpacked with wrong size!
  995. fi
  996. # end of 'man1/delete.1'
  997. fi
  998. if test -f 'man1/expunge.1' -a "${1}" != "-c" ; then 
  999.   echo shar: Will not clobber existing file \"'man1/expunge.1'\"
  1000. else
  1001. echo shar: Extracting \"'man1/expunge.1'\" \(4052 characters\)
  1002. sed "s/^X//" >'man1/expunge.1' <<'END_OF_FILE'
  1003. X.\"    $Source: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/expunge.1,v $
  1004. X.\"    $Author: jik $
  1005. X.\"    $Header: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/expunge.1,v 1.9 91/01/01 05:09:52 jik Exp $
  1006. X.\"
  1007. X.\" Copyright 1989 by the Massachusetts Institute of Technology.  All
  1008. X.\" rights reserved.  The file /usr/include/mit-copyright.h specifies
  1009. X.\" the terms and conditions for redistribution.
  1010. X.\"
  1011. X.\"
  1012. X.TH EXPUNGE 1 "January 27, 1988" "MIT Project Athena"
  1013. X.ds ]W MIT Project Athena
  1014. X.SH NAME
  1015. Xexpunge, purge \- permanent removal of deleted files
  1016. X.SH SYNOPSIS
  1017. X.B expunge
  1018. X[
  1019. X.B \-r
  1020. X] [
  1021. X.B \-i
  1022. X] [
  1023. X.B \-f
  1024. X] [
  1025. X.B \-t \fIn\fR
  1026. X] [
  1027. X.B \-n
  1028. X] [
  1029. X.B \-v
  1030. X] [
  1031. X.B \-l
  1032. X] [
  1033. X.B \-s
  1034. X] [
  1035. X.B \-m
  1036. X] [
  1037. X.B \-y
  1038. X] [
  1039. X.B \-\|\-
  1040. X] [ filename [ ... ]]
  1041. X.PP
  1042. X.B purge
  1043. X.PP
  1044. X.SH DESCRIPTION
  1045. X.I Expunge
  1046. Xand
  1047. X.I purge
  1048. Xpermanently remove files which have been marked for deletion using
  1049. X\fIdelete\fR(1).  Files removed with \fIexpunge\fR or \fIpurge\fR
  1050. Xcannot be recovered, and care should therefore be exercised in the
  1051. Xuse of these utilities.
  1052. X.PP
  1053. X.I Purge
  1054. Xis a simple utility which takes no command-line arguments.  When it is
  1055. Xexecuted, it searches through the user's entire home directory and
  1056. Xfinds all files that have been marked for deletion.  It then displays
  1057. Xa list of the files where are to be removed and prompts for
  1058. Xconfirmation.  A response from the user starting with the letter
  1059. X\fIy\fR will cause the files to be permanently expunged.
  1060. X.PP
  1061. XBecause
  1062. X.I purge
  1063. Xsearches through the user's entire home directory, it can take quite a
  1064. Xwhile to complete its search.  This is normal.
  1065. X.PP
  1066. XThe filenames passed to
  1067. X.I expunge
  1068. Xon the command-line can be directories (deleted or not deleted) or
  1069. Xdeleted files.  Deleted files or directories are always completely
  1070. Xexpunged, while the treatment of non-deleted directories depends on
  1071. Xthe
  1072. X.BR \-r
  1073. Xcommand-line option (see below).  If no command-line filenames are
  1074. Xspecified,
  1075. X.I expunge
  1076. Xdefaults to the current working directory.
  1077. X.PP
  1078. XFor information about wildcard use with \fIexpunge\fR, please see
  1079. X\fIundelete\fR(1).
  1080. X.PP
  1081. X.SH OPTIONS
  1082. X.I Expunge
  1083. Xaccepts the following command-line options:
  1084. X.TP
  1085. X.B \-r
  1086. XWhen a non-deleted directory is passed to \fIexpunge\fR, the 
  1087. X.BR \-r
  1088. Xoption causes the directory to be searced recursively for deleted
  1089. Xfiles.  If the recursive option is \fInot\fR specified, only the
  1090. Xdirect children of the non-deleted directory are examined.  A
  1091. Xrecursive search of a large directory can take quite a while.
  1092. X.TP
  1093. X.B \-i
  1094. XThe user is prompted for confirmation with the name of the file and
  1095. Xits size in kilobytes before each file or directory is
  1096. Xremoved.
  1097. X.TP
  1098. X.B \-f
  1099. XUsed in conjunction with the
  1100. X.BR \-l
  1101. Xoption, this option prevents 
  1102. X.I expunge
  1103. Xfrom prompting for confirmation after listing all the files that are
  1104. Xto be deleted.  Furthermore, it prevents the printing of error
  1105. Xmessages.
  1106. X.TP
  1107. X.B \-t\fIn\fR
  1108. XSpecifies the minimum age (in days) of files to be expunged, measured
  1109. Xas the length of time since the file was
  1110. X.IR delete d.
  1111. X.TP
  1112. X.B \-n
  1113. XNo file expunges are performed.  Instead,
  1114. X.I expunge
  1115. Xprints to the standard output the files that it would expunge were the
  1116. X.BR \-n
  1117. Xoption not specified.
  1118. X.TP
  1119. X.B \-v
  1120. XCauses 
  1121. X.I expunge
  1122. Xto report each file as it is expunged, as well as the size of the file
  1123. Xand a running total of the number of kilobytes expunged.
  1124. X.TP
  1125. X.B \-l
  1126. XCauses 
  1127. X.I expunge
  1128. Xto list all found files before expunging them, similar to the actions
  1129. Xof
  1130. X.I purge.
  1131. X.TP
  1132. X.B \-s
  1133. XSymbolic links are followed when searching for deleted files.
  1134. X.TP
  1135. X.B \-m
  1136. XMount points are followed when searching for deleted files.
  1137. X.TP
  1138. X.B \-y
  1139. XThe total number of kilobytes expunged is printed after
  1140. X.I expunge
  1141. Xis finished removing files.
  1142. X.TP
  1143. X.B \-\|\-
  1144. XTwo dashes indicate that all arguments following it are to be treated
  1145. Xas file names, even if they start with a dash.
  1146. X.SH "SEE ALSO"
  1147. Xdelete(1), undelete(1), lsdel(1), rm(1), rmdir(1)
  1148. X.SH AUTHOR
  1149. XJonathan I. Kamens (MIT-Project Athena)
  1150. X.SH RESTRICTIONS
  1151. XCopyright (c) 1989 by the Massachusetts Institute of Technology.  All
  1152. Xrights reserved.
  1153. X.IR Delete (1)
  1154. Xspecifies the terms and conditions for redistribution.
  1155. END_OF_FILE
  1156. if test 4052 -ne `wc -c <'man1/expunge.1'`; then
  1157.     echo shar: \"'man1/expunge.1'\" unpacked with wrong size!
  1158. fi
  1159. # end of 'man1/expunge.1'
  1160. fi
  1161. if test -f 'man1/lsdel.1' -a "${1}" != "-c" ; then 
  1162.   echo shar: Will not clobber existing file \"'man1/lsdel.1'\"
  1163. else
  1164. echo shar: Extracting \"'man1/lsdel.1'\" \(2148 characters\)
  1165. sed "s/^X//" >'man1/lsdel.1' <<'END_OF_FILE'
  1166. X.\"    $Source: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/lsdel.1,v $
  1167. X.\"    $Author: jik $
  1168. X.\"    $Header: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/lsdel.1,v 1.6 90/09/26 03:49:35 jik Exp $
  1169. X.\"
  1170. X.\" Copyright 1989 by the Massachusetts Institute of Technology.  All
  1171. X.\" rights reserved.  The file /usr/include/mit-copyright.h specifies
  1172. X.\" the terms and conditions for redistribution.
  1173. X.\"
  1174. X.\"
  1175. X.TH LSDEL 1 "January 27, 1988" "MIT Project Athena"
  1176. X.ds ]W MIT Project Athena
  1177. X.SH NAME
  1178. Xlsdel \- list deleted files
  1179. X.SH SYNOPSIS
  1180. X.B lsdel
  1181. X[
  1182. X.B \-d
  1183. X] [
  1184. X.B \-r
  1185. X] [
  1186. X.B \-t \fIn\fR
  1187. X] [
  1188. X.B \-s
  1189. X] [
  1190. X.B \-m
  1191. X] [
  1192. X.B \-y
  1193. X] [ filename [ ... ]]
  1194. X.PP
  1195. X.SH DESCRIPTION
  1196. X.I Lsdel
  1197. Xlists files that have been marked for deletion by the \fIdelete\fR(1)
  1198. Xprogram.
  1199. X.PP
  1200. XFor information about using wildcards with \fIlsdel\fR, see
  1201. X\fIundelete\fR(1).
  1202. X.PP
  1203. XFilenames passed to \fIlsdel\fR can be directories (non-deleted or
  1204. Xdeleted) or deleted files.  If a non-deleted directory is specified,
  1205. Xlsdel lists the deleted contents of that directory.  If the
  1206. X.BR \-r
  1207. Xoption is specified, all non-deleted children of the directory will be
  1208. Xsearched recursively for deleted files.  If no command-line filenames
  1209. Xare specified,
  1210. X.I lsdel
  1211. Xdefaults to the current working directory.
  1212. X.PP
  1213. X.I Lsdel
  1214. Xrecursively lists deleted directories by default.  This can be
  1215. Xdisabled with the
  1216. X.BR \-d
  1217. Xoption, which causes directory names, rather than their contents, to
  1218. Xbe listed.
  1219. X.PP
  1220. XThe
  1221. X.BR \-t
  1222. Xoption allows the user to specify a minimum age, in days, of files to
  1223. Xlist.  Only files that were
  1224. X.IR delete d
  1225. X\fIn\fR days or more ago will be listed.
  1226. X.PP
  1227. XThe
  1228. X.BR \-s
  1229. Xoptions tells
  1230. X.I lsdel
  1231. Xto follow symbolic links when searching for deleted files.  The
  1232. X.BR \-m
  1233. Xoption does the same thing for mount points.
  1234. X.PP
  1235. XThe
  1236. X.BR \-y
  1237. Xoption causes
  1238. X.I lsdel
  1239. Xto print the total amount of space taken up by all the files it lists.
  1240. X.SH "SEE ALSO"
  1241. Xdelete(1), undelete(1), purge(1), expunge(1), ls(1)
  1242. X.SH AUTHOR
  1243. XJonathan I. Kamens (MIT-Project Athena)
  1244. X.SH RESTRICTIONS
  1245. XCopyright (c) 1989 by the Massachusetts Institute of Technology.  All
  1246. Xrights reserved.
  1247. X.IR Delete (1)
  1248. Xspecifies the terms and conditions for redistribution.
  1249. END_OF_FILE
  1250. if test 2148 -ne `wc -c <'man1/lsdel.1'`; then
  1251.     echo shar: \"'man1/lsdel.1'\" unpacked with wrong size!
  1252. fi
  1253. # end of 'man1/lsdel.1'
  1254. fi
  1255. if test -f 'man1/purge.1' -a "${1}" != "-c" ; then 
  1256.   echo shar: Will not clobber existing file \"'man1/purge.1'\"
  1257. else
  1258. echo shar: Extracting \"'man1/purge.1'\" \(421 characters\)
  1259. sed "s/^X//" >'man1/purge.1' <<'END_OF_FILE'
  1260. X.\"    $Source: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/purge.1,v $
  1261. X.\"    $Author: jik $
  1262. X.\"    $Header: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/purge.1,v 1.1 89/01/27 04:50:13 jik Exp $
  1263. X.\"
  1264. X.\" Copyright 1989 by the Massachusetts Institute of Technology.  All
  1265. X.\" rights reserved.  The file /usr/include/mit-copyright.h specifies
  1266. X.\" the terms and conditions for redistribution.
  1267. X.\"
  1268. X.\"
  1269. X.so man1/expunge.1
  1270. END_OF_FILE
  1271. if test 421 -ne `wc -c <'man1/purge.1'`; then
  1272.     echo shar: \"'man1/purge.1'\" unpacked with wrong size!
  1273. fi
  1274. # end of 'man1/purge.1'
  1275. fi
  1276. if test -f 'man1/undelete.1' -a "${1}" != "-c" ; then 
  1277.   echo shar: Will not clobber existing file \"'man1/undelete.1'\"
  1278. else
  1279. echo shar: Extracting \"'man1/undelete.1'\" \(3506 characters\)
  1280. sed "s/^X//" >'man1/undelete.1' <<'END_OF_FILE'
  1281. X.\"    $Source: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/undelete.1,v $
  1282. X.\"    $Author: jik $
  1283. X.\"    $Header: /afs/athena.mit.edu/user/j/jik/delete/src/man1/RCS/undelete.1,v 1.5 89/11/02 07:13:26 jik Exp $
  1284. X.\" Copyright 1989 by the Massachusetts Institute of Technology.  All
  1285. X.\" rights reserved.  The file /usr/include/mit-copyright.h specifies
  1286. X.\" the terms and conditions for redistribution.
  1287. X.\"
  1288. X.\"
  1289. X.TH UNDELETE 1 "January 26, 1988" "MIT Project Athena"
  1290. X.ds ]W MIT Project Athena
  1291. X.SH NAME
  1292. Xundelete \- recover files removed by delete
  1293. X.SH SYNOPSIS
  1294. X.B undelete
  1295. X[
  1296. X.B \-r
  1297. X] [
  1298. X.B \-i
  1299. X] [
  1300. X.B \-f
  1301. X] [
  1302. X.B \-v
  1303. X] [
  1304. X.B \-n
  1305. X] [
  1306. X.B \-R
  1307. X] [
  1308. X.B \-\|\-
  1309. X] [ filename [ ... ]]
  1310. X.PP
  1311. X.DESCRIPTION
  1312. X.I Undelete
  1313. Xrecovers files and directories that have been marked for permanent removal by 
  1314. X\fIdelete\fR(1), but have not
  1315. Xyet been removed.
  1316. X.PP
  1317. XFilenames passed to
  1318. X.I undelete
  1319. Xcan be directories or deleted files.
  1320. XIf a directory that is not deleted is passed to
  1321. X.I undelete,
  1322. Xthen the deleted files or directories in it will be restored; if the
  1323. Xrecursive option is specified, then all deleted files or directories
  1324. Xin any of its children will be restored as well.
  1325. X.PP
  1326. XThe shell wildcards \fI*\fR and \fI?\fR, as well as shell brace
  1327. Xnotation using \fI[\fR and \fI]\fR, are interpreted correctly by
  1328. X.I undelete.
  1329. XIt is possible to pass wildcards to the program without the wildcards
  1330. Xbeing intercepted by the shell by setting
  1331. X.I noglob
  1332. X(in \fIcsh\fR) or by quoting the wildcards.  To delete a file that
  1333. Xactually has a wildcard in its name, you must precede the quoted
  1334. Xwildcard with a quoted backslash.
  1335. X.PP
  1336. XIf no files are specified on the command line,
  1337. X.I undelete
  1338. Xgoes into interactive mode.  In interactive mode, the user is prompted
  1339. Xto enter files to be restored, one file per line.  Typing a carriage
  1340. Xreturn on an empty prompt line exits the program.
  1341. X.PP
  1342. XWildcards and quoting backslashes can be entered directly at the
  1343. Xprompt without any shell interference (which is the
  1344. Xmain reason there is an interactive mode).
  1345. X.SH OPTIONS
  1346. X.I Undelete
  1347. Xaccepts the following command-line options:
  1348. X.TP
  1349. X.B \-r
  1350. XIf a specified file is a directory, the directory and all of its
  1351. Xchildren are restored recursively.
  1352. X.TP
  1353. X.B \-i
  1354. XThe user is prompted for confirmation before each file or directory is
  1355. Xrestored.  This is not the same as the interactive file name entry
  1356. Xmode which is automatically activated when no files are specified on
  1357. Xthe command line.
  1358. X.TP
  1359. X.B \-f
  1360. XPrevents
  1361. X.I undelete
  1362. Xfrom reporting errors.  Further, if an intact (undeleted) version of a
  1363. Xfile which is requested for undeletion exists, then
  1364. X.I undelete
  1365. Xwill not prompt for confirmation before overwriting the undeleted file
  1366. Xwith the recovered one.
  1367. X.TP
  1368. X.B \-v
  1369. XCauses
  1370. X.I undelete
  1371. Xto report each file as it is restored.  Also, causes an introductory
  1372. Xmessage to be printed when entering interactive mode.
  1373. X.TP
  1374. X.B \-n
  1375. XNo file recoveries are performed.  Instead,
  1376. X.I undelete
  1377. Xprints to the standard output the files that it would recover were the
  1378. X.B \-n
  1379. Xoption not specified.
  1380. X.TP
  1381. X.B \-R
  1382. XPrevents
  1383. X.I undelete
  1384. Xfrom restoring the contents of directories in any case.
  1385. X.TP
  1386. X.B \-\|\-
  1387. XTwo dashes indicate that all arguments following it are to be treated as file
  1388. Xnames, even if they start with a dash.
  1389. X.SH "SEE ALSO"
  1390. Xdelete(1), purge(1), expunge(1), lsdel(1), rm(1), rmdir(1)
  1391. X.SH AUTHOR
  1392. XJonathan I. Kamens (MIT-Project Athena)
  1393. X.SH RESTRICTIONS
  1394. XCopyright (c) 1989 by the Massachusetts Institute of Technology.  All
  1395. Xrights reserved.
  1396. X.IR Delete (1)
  1397. Xspecifies the terms and conditions for redistribution.
  1398. END_OF_FILE
  1399. if test 3506 -ne `wc -c <'man1/undelete.1'`; then
  1400.     echo shar: \"'man1/undelete.1'\" unpacked with wrong size!
  1401. fi
  1402. # end of 'man1/undelete.1'
  1403. fi
  1404. if test -f 'mit-copyright.h' -a "${1}" != "-c" ; then 
  1405.   echo shar: Will not clobber existing file \"'mit-copyright.h'\"
  1406. else
  1407. echo shar: Extracting \"'mit-copyright.h'\" \(1030 characters\)
  1408. sed "s/^X//" >'mit-copyright.h' <<'END_OF_FILE'
  1409. X/*
  1410. X
  1411. XCopyright 1987,1988,1991 by the Massachusetts Institute of Technology
  1412. X
  1413. XAll rights reserved.
  1414. X
  1415. XPermission to use, copy, modify, and distribute this software and its
  1416. Xdocumentation for any purpose and without fee is hereby granted,
  1417. Xprovided that the above copyright notice appear in all copies and that
  1418. Xboth that copyright notice and this permission notice appear in
  1419. Xsupporting documentation, and that the name of the Massachusetts
  1420. XInstitute of Technology (M.I.T.) not be used in advertising or publicity
  1421. Xpertaining to distribution of the software without specific, written
  1422. Xprior permission.
  1423. X
  1424. XM.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1425. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1426. XM.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1427. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1428. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1429. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1430. XSOFTWARE.
  1431. X
  1432. X*/
  1433. END_OF_FILE
  1434. if test 1030 -ne `wc -c <'mit-copyright.h'`; then
  1435.     echo shar: \"'mit-copyright.h'\" unpacked with wrong size!
  1436. fi
  1437. # end of 'mit-copyright.h'
  1438. fi
  1439. if test -f 'pattern.h' -a "${1}" != "-c" ; then 
  1440.   echo shar: Will not clobber existing file \"'pattern.h'\"
  1441. else
  1442. echo shar: Extracting \"'pattern.h'\" \(1199 characters\)
  1443. sed "s/^X//" >'pattern.h' <<'END_OF_FILE'
  1444. X/*
  1445. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/pattern.h,v $
  1446. X * $Author: jik $
  1447. X * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/pattern.h,v 1.5 89/11/06 19:54:32 jik Exp $
  1448. X * 
  1449. X * This program is part of a package including delete, undelete,
  1450. X * lsdel, expunge and purge.  The software suite is meant as a
  1451. X * replacement for rm which allows for file recovery.
  1452. X * 
  1453. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  1454. X * For copying and distribution information, see the file "mit-copyright.h."
  1455. X */
  1456. X#include "mit-copyright.h"
  1457. X
  1458. Xint add_str();
  1459. Xint add_arrays();
  1460. Xint find_contents();
  1461. Xint find_deleted_contents();
  1462. Xint find_deleted_contents_recurs();
  1463. Xint find_matches();
  1464. Xint find_deleted_matches();
  1465. Xint find_recurses();
  1466. Xint find_deleted_recurses();
  1467. X
  1468. X#define FIND_DELETED        (1<<0)
  1469. X#define FIND_UNDELETED        (1<<1)
  1470. X#define RECURS_FIND_DELETED    (1<<2)
  1471. X#define RECURS_FIND_UNDELETED    (1<<3)
  1472. X#define RECURS_DELETED        (1<<4)
  1473. X#define FOLLW_LINKS        (1<<5)
  1474. X#define FOLLW_MOUNTPOINTS    (1<<6)
  1475. X#define FIND_DOTFILES        (1<<7)
  1476. X#define FIND_CONTENTS        (1<<8)
  1477. X#define SUPPRESS_WARNINGS    (1<<9)
  1478. X#define RECURS            (RECURS_FIND_DELETED | RECURS_FIND_UNDELETED |\
  1479. X                 RECURS_DELETED | FIND_CONTENTS)
  1480. END_OF_FILE
  1481. if test 1199 -ne `wc -c <'pattern.h'`; then
  1482.     echo shar: \"'pattern.h'\" unpacked with wrong size!
  1483. fi
  1484. # end of 'pattern.h'
  1485. fi
  1486. if test -f 'shell_regexp.c' -a "${1}" != "-c" ; then 
  1487.   echo shar: Will not clobber existing file \"'shell_regexp.c'\"
  1488. else
  1489. echo shar: Extracting \"'shell_regexp.c'\" \(3189 characters\)
  1490. sed "s/^X//" >'shell_regexp.c' <<'END_OF_FILE'
  1491. X/*
  1492. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/shell_regexp.c,v $
  1493. X * $Author: jik $
  1494. X *
  1495. X * This program is part of a package including delete, undelete,
  1496. X * lsdel, expunge and purge.  The software suite is meant as a
  1497. X * replacement for rm which allows for file recovery.
  1498. X * 
  1499. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  1500. X * For copying and distribution information, see the file "mit-copyright.h."
  1501. X */
  1502. X
  1503. X#if (!defined(lint) && !defined(SABER))
  1504. X     static char rcsid_shell_regexp_c[] = "$Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/shell_regexp.c,v 1.2 89/11/06 21:27:16 jik Exp $";
  1505. X#endif
  1506. X
  1507. X#include <com_err.h>
  1508. X#include "shell_regexp.h"
  1509. X#include "delete_errs.h"
  1510. X#include "errors.h"
  1511. X#include "mit-copyright.h"
  1512. X
  1513. Xstatic int real_cmp();
  1514. X
  1515. X/*
  1516. X * This is a simple pattern matcher that takes a pattern string and
  1517. X * another string (theoretically a filename) and checks if the second
  1518. X * string matches the pattern string using shell special characters
  1519. X * (i.e. it recognizes \, ?, *, [, ]).  It also special cases dot
  1520. X * files (i.e. * doesn't match files that start with periods, and
  1521. X * neither will ?*, and neither will [.]*).
  1522. X */
  1523. X
  1524. Xint reg_cmp(pattern, filename)
  1525. Xchar *pattern, *filename;
  1526. X{
  1527. X     /* First, dot file special cases */
  1528. X     if ((*filename == '.') && (*pattern != '.'))
  1529. X      return REGEXP_NO_MATCH;
  1530. X
  1531. X     return real_cmp(pattern, filename);
  1532. X}
  1533. X
  1534. Xstatic int real_cmp(pattern, filename)
  1535. Xchar *pattern, *filename;
  1536. X{
  1537. X     if (*pattern == '\0') {
  1538. X      if (*filename == '\0')
  1539. X           return REGEXP_MATCH;
  1540. X      else
  1541. X           return REGEXP_NO_MATCH;
  1542. X     }
  1543. X     
  1544. X     if (*pattern == '*') {
  1545. X      int retval;
  1546. X      char *ptr;
  1547. X      
  1548. X      if (*(pattern + 1) == '\0')
  1549. X           /* asterisk by itself matches anything */
  1550. X           return REGEXP_MATCH;
  1551. X      for (ptr = filename; *ptr; ptr++)
  1552. X           if ((retval = real_cmp(pattern + 1, ptr)) != REGEXP_NO_MATCH)
  1553. X            return retval;
  1554. X      return REGEXP_NO_MATCH;
  1555. X     }
  1556. X
  1557. X     if (*filename == '\0')
  1558. X      return REGEXP_NO_MATCH;
  1559. X     
  1560. X     if (*pattern == '?')
  1561. X      return real_cmp(pattern + 1, filename + 1);
  1562. X
  1563. X     if (*pattern == '\\') {
  1564. X      if (*(pattern + 1) == '\0') {
  1565. X           set_error(REGEXP_MISSING_QUOTED_CHAR);
  1566. X           return -1;
  1567. X      }
  1568. X      if (*(pattern + 1) == *filename)
  1569. X           return real_cmp(pattern + 2, filename + 1);
  1570. X      else
  1571. X           return REGEXP_NO_MATCH;
  1572. X     }
  1573. X
  1574. X     if (*pattern == '[') {
  1575. X      char *ptr, *end_ptr;
  1576. X
  1577. X      for (end_ptr = pattern + 1; (*end_ptr != '\0') && (*end_ptr != ']');
  1578. X           end_ptr++) ;
  1579. X      if (*end_ptr == '\0') {
  1580. X           set_error(REGEXP_MISSING_BRACE);
  1581. X           return -1;
  1582. X      }
  1583. X      if (end_ptr == pattern + 1) {
  1584. X           set_error(REGEXP_EMPTY_BRACES);
  1585. X           return -1;
  1586. X      }
  1587. X      for (ptr = pattern + 1; ptr < end_ptr; ptr++) {
  1588. X           if ((*(ptr + 1) == '-') && (*(ptr + 2) != ']')) {
  1589. X            if ((*ptr <= *filename) && (*(ptr + 2) >= *filename))
  1590. X             return real_cmp(end_ptr + 1, filename + 1);
  1591. X            else {
  1592. X             ptr += 2;
  1593. X             continue;
  1594. X            }
  1595. X           }
  1596. X           if (*ptr == *filename)
  1597. X            return real_cmp(end_ptr + 1, filename + 1);
  1598. X      }
  1599. X
  1600. X      return REGEXP_NO_MATCH;
  1601. X     }
  1602. X            
  1603. X     if (*pattern == *filename)
  1604. X      return real_cmp(pattern + 1, filename + 1);
  1605. X     else
  1606. X      return REGEXP_NO_MATCH;
  1607. X}
  1608. END_OF_FILE
  1609. if test 3189 -ne `wc -c <'shell_regexp.c'`; then
  1610.     echo shar: \"'shell_regexp.c'\" unpacked with wrong size!
  1611. fi
  1612. # end of 'shell_regexp.c'
  1613. fi
  1614. if test -f 'shell_regexp.h' -a "${1}" != "-c" ; then 
  1615.   echo shar: Will not clobber existing file \"'shell_regexp.h'\"
  1616. else
  1617. echo shar: Extracting \"'shell_regexp.h'\" \(536 characters\)
  1618. sed "s/^X//" >'shell_regexp.h' <<'END_OF_FILE'
  1619. X/*
  1620. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/shell_regexp.h,v $
  1621. X * $Author: jik $
  1622. X *
  1623. X * This program is part of a package including delete, undelete,
  1624. X * lsdel, expunge and purge.  The software suite is meant as a
  1625. X * replacement for rm which allows for file recovery.
  1626. X * 
  1627. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  1628. X * For copying and distribution information, see the file "mit-copyright.h."
  1629. X */
  1630. X#include "mit-copyright.h"
  1631. X
  1632. Xextern int reg_cmp();
  1633. X
  1634. X#define REGEXP_MATCH 1
  1635. X#define REGEXP_NO_MATCH 0
  1636. END_OF_FILE
  1637. if test 536 -ne `wc -c <'shell_regexp.h'`; then
  1638.     echo shar: \"'shell_regexp.h'\" unpacked with wrong size!
  1639. fi
  1640. # end of 'shell_regexp.h'
  1641. fi
  1642. if test -f 'stack.c' -a "${1}" != "-c" ; then 
  1643.   echo shar: Will not clobber existing file \"'stack.c'\"
  1644. else
  1645. echo shar: Extracting \"'stack.c'\" \(3688 characters\)
  1646. sed "s/^X//" >'stack.c' <<'END_OF_FILE'
  1647. X/*
  1648. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/stack.c,v $
  1649. X * $Author: jik $
  1650. X *
  1651. X * This program is part of a package including delete, undelete,
  1652. X * lsdel, expunge and purge.  The software suite is meant as a
  1653. X * replacement for rm which allows for file recovery.
  1654. X * 
  1655. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  1656. X * For copying and distribution information, see the file "mit-copyright.h."
  1657. X */
  1658. X
  1659. X#if (!defined(lint) && !defined(SABER))
  1660. X     static char rcsid_stack_c[] = "$Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/stack.c,v 1.8 90/09/26 03:45:37 jik Exp $";
  1661. X#endif
  1662. X
  1663. X#include <sys/types.h>
  1664. X#include <stdio.h>
  1665. X#include <errno.h>
  1666. X#include "stack.h"
  1667. X#include "delete_errs.h"
  1668. X#include "errors.h"
  1669. X#include "mit-copyright.h"
  1670. X#include "util.h"
  1671. X
  1672. Xextern char *realloc();
  1673. Xextern int errno;
  1674. X
  1675. X#define STACK_INC     25
  1676. X
  1677. X
  1678. X
  1679. Xint dostack(data, op, bytes)
  1680. Xcaddr_t data;
  1681. Xint op, bytes;
  1682. X{
  1683. X     static caddr_t stack = (caddr_t) NULL;
  1684. X     static int size = 0, count = 0;
  1685. X     
  1686. X     switch (op) {
  1687. X     case EMPTY_STACK:
  1688. X      if (size) {
  1689. X           free(stack);
  1690. X           stack = (caddr_t) NULL;
  1691. X           size = count = 0;
  1692. X      }
  1693. X#ifdef STACK_DEBUG
  1694. X      fprintf(stderr, "dostack: return 1 (EMPTY_STACK).\n");
  1695. X#endif
  1696. X      return 0;
  1697. X     case STACK_PUSH:
  1698. X      if (bytes == 0) {
  1699. X#ifdef STACK_DEBUG
  1700. X           fprintf(stderr, "Pushing 0 bytes at %d offset.\n", count);
  1701. X           fprintf(stderr, "dostack: return 2 (STACK_PUSH).\n");
  1702. X#endif
  1703. X           return 0;
  1704. X      }
  1705. X      if (size - count < bytes) {
  1706. X           do
  1707. X            size += STACK_INC;
  1708. X           while (size - count < bytes);
  1709. X           stack = (caddr_t) (stack ? realloc((char *) stack,
  1710. X                          (unsigned) size) :
  1711. X                  Malloc((unsigned) size));
  1712. X           if (! stack) {
  1713. X            size = count = 0;
  1714. X            set_error(errno);
  1715. X            error("Malloc");
  1716. X#ifdef STACK_DEBUG
  1717. X            fprintf(stderr, "dostack: return 3 (STACK_PUSH).\n");
  1718. X#endif
  1719. X            return error_code;
  1720. X           }
  1721. X      }
  1722. X#ifdef STACK_DEBUG
  1723. X      fprintf(stderr, "Pushing %d bytes at %d offset.\n", bytes, count);
  1724. X#endif
  1725. X#if defined(SYSV) || (defined(__STDC__) && !defined(__HIGHC__))
  1726. X      memcpy(stack + count, data, bytes);
  1727. X#else
  1728. X      bcopy(data, stack + count, bytes);
  1729. X#endif
  1730. X      count += bytes;
  1731. X#ifdef STACK_DEBUG
  1732. X      fprintf(stderr, "dostack: return 4 (STACK_PUSH).\n");
  1733. X#endif
  1734. X      return 0;
  1735. X     case STACK_POP:
  1736. X      if (bytes == 0) {
  1737. X#ifdef STACK_DEBUG
  1738. X           fprintf(stderr, "Popping 0 bytes at %d offset.\n", count);
  1739. X           fprintf(stderr, "dostack: return 5 (STACK_POP).\n");
  1740. X#endif
  1741. X           return 0;
  1742. X      }
  1743. X      if (count == 0) {
  1744. X           set_status(STACK_EMPTY);
  1745. X#ifdef STACK_DEBUG
  1746. X           fprintf(stderr, "dostack: return 6 (STACK_POP).\n");
  1747. X#endif
  1748. X           return error_code;
  1749. X      }
  1750. X      else {
  1751. X           int newblocks, newsize;
  1752. X
  1753. X           count -= bytes;
  1754. X#ifdef STACK_DEBUG
  1755. X           fprintf(stderr, "Popping %d bytes at %d offset.\n", bytes,
  1756. X               count);
  1757. X#endif
  1758. X#if defined(SYSV) || (defined(__STDC__) && !defined(__HIGHC__))
  1759. X           memcpy(data, stack + count, bytes);
  1760. X#else
  1761. X           bcopy(stack + count, data, bytes);
  1762. X#endif
  1763. X           newblocks = count / STACK_INC + ((count % STACK_INC) ? 1 : 0);
  1764. X           newsize = newblocks * STACK_INC;
  1765. X           if (newsize < size) {
  1766. X            size = newsize;
  1767. X            stack = (caddr_t) realloc((char *) stack, (unsigned) size);
  1768. X            if ((size != 0) && (! stack)) {
  1769. X             set_error(errno);
  1770. X             error("realloc");
  1771. X#ifdef STACK_DEBUG
  1772. X             fprintf(stderr, "dostack: return 7 (STACK_POP).\n");
  1773. X#endif
  1774. X             return error_code;
  1775. X            }
  1776. X           }
  1777. X#ifdef STACK_DEBUG
  1778. X           fprintf(stderr, "dostack: return 8 (STACK_POP).\n");
  1779. X#endif
  1780. X           return 0;
  1781. X      }
  1782. X     default:
  1783. X      set_error(STACK_BAD_OP);
  1784. X#ifdef STACK_DEBUG
  1785. X      fprintf(stderr, "dostack: return 9.\n");
  1786. X#endif
  1787. X      return error_code;
  1788. X     }
  1789. X}
  1790. END_OF_FILE
  1791. if test 3688 -ne `wc -c <'stack.c'`; then
  1792.     echo shar: \"'stack.c'\" unpacked with wrong size!
  1793. fi
  1794. # end of 'stack.c'
  1795. fi
  1796. if test -f 'stack.h' -a "${1}" != "-c" ; then 
  1797.   echo shar: Will not clobber existing file \"'stack.h'\"
  1798. else
  1799. echo shar: Extracting \"'stack.h'\" \(817 characters\)
  1800. sed "s/^X//" >'stack.h' <<'END_OF_FILE'
  1801. X/*
  1802. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/stack.h,v $
  1803. X * $Author: jik $
  1804. X * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/stack.h,v 1.2 89/11/06 21:26:50 jik Exp $
  1805. X * 
  1806. X * This file is part of a package including delete, undelete,
  1807. X * lsdel, expunge and purge.  The software suite is meant as a
  1808. X * replacement for rm which allows for file recovery.
  1809. X * 
  1810. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  1811. X * For copying and distribution information, see the file "mit-copyright.h."
  1812. X */
  1813. X#include "mit-copyright.h"
  1814. X
  1815. X#define STACK_PUSH     0
  1816. X#define STACK_POP    1
  1817. X#define EMPTY_STACK    2
  1818. X
  1819. X#define push(data, size)    dostack((caddr_t) data, STACK_PUSH, size)
  1820. X#define pop(data, size)        dostack((caddr_t) data, STACK_POP, size)
  1821. X#define popall()        dostack((caddr_t) NULL, EMPTY_STACK, 0)
  1822. X     
  1823. END_OF_FILE
  1824. if test 817 -ne `wc -c <'stack.h'`; then
  1825.     echo shar: \"'stack.h'\" unpacked with wrong size!
  1826. fi
  1827. # end of 'stack.h'
  1828. fi
  1829. if test -f 'undelete.h' -a "${1}" != "-c" ; then 
  1830.   echo shar: Will not clobber existing file \"'undelete.h'\"
  1831. else
  1832. echo shar: Extracting \"'undelete.h'\" \(748 characters\)
  1833. sed "s/^X//" >'undelete.h' <<'END_OF_FILE'
  1834. X/*
  1835. X * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/undelete.h,v $
  1836. X * $Author: jik $
  1837. X * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/undelete.h,v 1.4 89/10/23 13:09:09 jik Exp $
  1838. X * 
  1839. X * This program is part of a package including delete, undelete,
  1840. X * lsdel, expunge and purge.  The software suite is meant as a
  1841. X * replacement for rm which allows for file recovery.
  1842. X * 
  1843. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  1844. X * For copying and distribution information, see the file "mit-copyright.h."
  1845. X */
  1846. X#include "mit-copyright.h"
  1847. X
  1848. X#define DELETEPREFIX ".#"
  1849. X#define DELETEREPREFIX "\\.#"
  1850. X
  1851. Xtypedef struct {
  1852. X     char *user_name;
  1853. X     char *real_name;
  1854. X} listrec;
  1855. X
  1856. Xint sort_files();
  1857. Xint unique();
  1858. X
  1859. Xint get_the_files();
  1860. END_OF_FILE
  1861. if test 748 -ne `wc -c <'undelete.h'`; then
  1862.     echo shar: \"'undelete.h'\" unpacked with wrong size!
  1863. fi
  1864. # end of 'undelete.h'
  1865. fi
  1866. if test -f 'util.h' -a "${1}" != "-c" ; then 
  1867.   echo shar: Will not clobber existing file \"'util.h'\"
  1868. else
  1869. echo shar: Extracting \"'util.h'\" \(1222 characters\)
  1870. sed "s/^X//" >'util.h' <<'END_OF_FILE'
  1871. X/*
  1872. X * $Source: /afs/athena.mit.edu/astaff/project/delete/src/RCS/util.h,v $
  1873. X * $Author: jik $
  1874. X * $Header: /afs/athena.mit.edu/astaff/project/delete/src/RCS/util.h,v 1.11 91/02/20 17:28:33 jik Exp $
  1875. X * 
  1876. X * This file is part of a package including delete, undelete,
  1877. X * lsdel, expunge and purge.  The software suite is meant as a
  1878. X * replacement for rm which allows for file recovery.
  1879. X * 
  1880. X * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  1881. X * For copying and distribution information, see the file "mit-copyright.h."
  1882. X */
  1883. X#include "mit-copyright.h"
  1884. X
  1885. X#include <sys/stat.h>
  1886. X#ifndef S_IFLNK
  1887. X#define lstat stat
  1888. X#endif
  1889. X
  1890. Xchar *append();
  1891. Xchar *convert_to_user_name();
  1892. Xchar *firstpart();
  1893. Xchar *lastpart();
  1894. Xchar *strindex();
  1895. Xchar *strrindex();
  1896. X#ifdef MALLOC_DEBUG
  1897. Xchar *Malloc();
  1898. X#else
  1899. X#define Malloc(a) malloc(a)
  1900. Xextern char *malloc();
  1901. X#endif
  1902. X
  1903. Xint is_mountpoint(), is_link();
  1904. X
  1905. X#define is_dotfile(A) ((*A == '.') && \
  1906. X               ((*(A + 1) == '\0') || \
  1907. X            ((*(A + 1) == '.') && \
  1908. X             (*(A + 2) == '\0'))))
  1909. X
  1910. X#define is_deleted(A) ((*A == '.') && (*(A + 1) == '#'))
  1911. X
  1912. X /* It would be BAD to pass something with a ++ anywhere near it into */
  1913. X /* this macro!                               */
  1914. X#define Opendir(dir) opendir(*(dir) ? (dir) : ".")
  1915. END_OF_FILE
  1916. if test 1222 -ne `wc -c <'util.h'`; then
  1917.     echo shar: \"'util.h'\" unpacked with wrong size!
  1918. fi
  1919. # end of 'util.h'
  1920. fi
  1921. echo shar: End of archive 1 \(of 4\).
  1922. cp /dev/null ark1isdone
  1923. MISSING=""
  1924. for I in 1 2 3 4 ; do
  1925.     if test ! -f ark${I}isdone ; then
  1926.     MISSING="${MISSING} ${I}"
  1927.     fi
  1928. done
  1929. if test "${MISSING}" = "" ; then
  1930.     echo You have unpacked all 4 archives.
  1931.     rm -f ark[1-9]isdone
  1932. else
  1933.     echo You still need to unpack the following archives:
  1934.     echo "        " ${MISSING}
  1935. fi
  1936. ##  End of shell archive.
  1937. exit 0
  1938.  
  1939. exit 0 # Just in case...
  1940. -- 
  1941. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1942. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1943. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1944. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1945.